Custom optimization

(inspired by stronglifts)

This notebook shows features of streprogen, the Python strength program generator.

Contributions to the code are welcome. :)

[1]:
!pip install streprogen matplotlib --quiet

Imports

[2]:
from streprogen import Program, reps_to_intensity, progression_diffeq
import matplotlib.pyplot as plt
import functools

The default optimizer

[3]:
program = Program(duration=4)

with program.Day():
    program.DynamicExercise(name="Squat", start_weight=100)

program.render()
print(program)
----------------------------------------------------------------
Program: Untitled

Program parameters
  duration: 4
  reps_per_exercise: 25
  intensity: 83
  units: kg
----------------------------------------------------------------
Exercise information
  Day 1
   Squat   100kg -> 106kg
    reps: [3, 8]   weekly inc.: 1.5%
----------------------------------------------------------------
Program
 Week 1
  Day 1
   Squat   8 x 75kg    7 x 77.5kg  7 x 77.5kg  7 x 77.5kg

 Week 2
  Day 1
   Squat   6 x 82.5kg  6 x 82.5kg  6 x 82.5kg  5 x 87.5kg  4 x 90kg

 Week 3
  Day 1
   Squat   6 x 85kg    5 x 87.5kg  4 x 92.5kg  4 x 92.5kg  4 x 92.5kg

 Week 4
  Day 1
   Squat   5 x 90kg    4 x 92.5kg  4 x 92.5kg  4 x 92.5kg  3 x 95kg

----------------------------------------------------------------

Customizing the optimizer

To customize the optimizer, change max_diff and max_unique below.

[4]:
from streprogen import RepSchemeGenerator, RepSchemeOptimizer
[5]:
program = Program(duration=4)


# Create a generator
generator = RepSchemeGenerator(
    max_diff=4,   # Maximum difference between two consecutive sets.
    max_unique=4, # Maximum unique sets in the solution.
)

# Override the default optimizer in the program
program.optimizer = RepSchemeOptimizer(generator=generator)

with program.Day():
    program.DynamicExercise(name="Squat", start_weight=100)

program.render()
print(program)
----------------------------------------------------------------
Program: Untitled

Program parameters
  duration: 4
  reps_per_exercise: 25
  intensity: 83
  units: kg
----------------------------------------------------------------
Exercise information
  Day 1
   Squat   100kg -> 106kg
    reps: [3, 8]   weekly inc.: 1.5%
----------------------------------------------------------------
Program
 Week 1
  Day 1
   Squat   8 x 75kg    8 x 75kg    7 x 77.5kg  4 x 87.5kg  3 x 90kg

 Week 2
  Day 1
   Squat   7 x 80kg    7 x 80kg    6 x 82.5kg  4 x 90kg    3 x 92.5kg

 Week 3
  Day 1
   Squat   6 x 85kg    6 x 85kg    5 x 87.5kg  3 x 95kg    3 x 95kg

 Week 4
  Day 1
   Squat   5 x 90kg    4 x 92.5kg  4 x 92.5kg  4 x 92.5kg  3 x 95kg

----------------------------------------------------------------

Further customization is possible - please see the source code for how to inject more custom behavoirs.